﻿using System;
using Xilium.CefGlue;

namespace CefWinform.BS
{
    public class BsClient : CefClient
    {
        private readonly CefLifeSpanHandler lifeSpanHandler;
        private readonly CefDownloadHandler downloadHandler;
        private readonly CefContextMenuHandler contextMenuHandler;
        public event EventHandler OnCreated;
        public BsClient()
        {
            this.lifeSpanHandler = new BsLifeSpanHandler(this);
            this.downloadHandler = new BsDownloadHandler();
        }
        protected override CefLifeSpanHandler GetLifeSpanHandler()
        {
            return this.lifeSpanHandler;
        }
        protected override CefDownloadHandler GetDownloadHandler()
        {
            return this.downloadHandler;
        }
        protected override CefContextMenuHandler GetContextMenuHandler()
        {
            return this.contextMenuHandler;
        }
        public void Created(CefBrowser bs)
        {
            if (this.OnCreated != null)
            {
                this.OnCreated(bs, EventArgs.Empty);
            }
        }
    }
}